<script setup lang='ts'>
import { ref, reactive } from "vue"
import { storeToRefs } from "pinia"

import { orderDetailProStore } from './detailorder'


const onlyTableOpeDetail = ref()
const { tableProp, listSearch, pageParams, addAndEditRef, } = storeToRefs(orderDetailProStore())
const { getDate1 } = orderDetailProStore()
defineOptions({
    name: 'addProductLink'
})
const emit = defineEmits(['refresh'])


const dialogBasic = ref({
    title: "订单详情",
    visible: false,
    width: 1200,
    height: 600,
    showFooter: false,
    marginTop: "5vh",
})


const addSupply = reactive<any>({

})




//显示弹框
const show = async (type: string, row?: any) => {
    listSearch.value.pageNum = 1
    listSearch.value.pageSize = 20
    //  初始化 全部清空 2 根据具体加入参数
    Object.keys(listSearch.value.condition).forEach((it: any) => {
        console.log(it);

        // @ts-ignore
        listSearch.value.condition[it] = null
    })
    if (type == 'productCode') {
        dialogBasic.value.title = '线上产品运营订单详情'
        listSearch.value.condition.productCode = row.productCode
        listSearch.value.condition.supplierCode = row.supplierCode
    }
    if (type == 'channelCode') {
        dialogBasic.value.title = '线上渠道运营订单详情'
        listSearch.value.condition.isQueryChannelStatistics  = 1

        listSearch.value.condition.channelCode = row.channelCode
        listSearch.value.condition.productCode = row.productCode
        listSearch.value.condition.supplierCode = row.supplierCode
    }
    await getDate1('search')
    dialogBasic.value.visible = true
}
const onClose = () => {
    // 清空数据
    Object.keys(listSearch.value.condition).forEach((it: any) => {
        // @ts-ignore
        listSearch.value.condition[it] = null
    })
    listSearch.value.pageNum = 1
    listSearch.value.pageSize = 20
    dialogBasic.value.visible = false
}

const onConfirm = async () => {

}

const handPage = (params: any) => {
    listSearch.value.pageNum = params.pageNum
    listSearch.value.pageSize = params.pageSize
    getDate1('search')
}
const getData = (type: string) => {
    if (type == 'reset') onlyTableOpeDetail.value.initPagination()

    getDate1(type)
}
defineExpose({
    show
})
</script>

<template>
    <SysDialog :title="dialogBasic.title" :width="dialogBasic.width" :height="dialogBasic.height"
        :show-footer="dialogBasic.showFooter" :visible="dialogBasic.visible" :margin-top="dialogBasic.marginTop"
        @on-close="onClose" @on-confirm="onConfirm">
        <template v-slot:content>
            <div class="demo-ruleForm">
                <div class="card-1">
                    <searchPanel @refresh="getData('reset')">
                        <!-- 查询面板 -->
                        <template v-slot:search>

                        </template>
                        <!-- 字段添加 -->
                        <template v-slot:edit>

                        </template>
                    </searchPanel>
                </div>
                <div class="card-2">
                    <!-- table数据 -->
                    <!-- <h1>productOnlineOperation</h1> -->
                    <OnlyTable ref="onlyTableOpeDetail" class="card-2" :tableProps="tableProp"
                        :pageTotal="pageParams.total" @get-page="handPage" :tableData="pageParams.tableData"
                        :tableHeight="pageParams.tableHeight" :loading="pageParams.loadIng">
                        <template #pageViews="scope">
                        </template>
                    </OnlyTable>
                </div>
            </div>

        </template>
    </SysDialog>
</template>

<style lang='scss' scoped>
.demo-ruleForm {
    height: 600px;
    // overflow: auto;
}
</style>
